﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using UserInfo;
using Base;

public partial class member_UserInfo_ChangePassword : nspBase.MemberBasePge
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!CheckCookies())
        {
            Response.Redirect("../../Login/login.aspx");
            return;
        }
        this.HiddUserID.Value=Base.BasePage.GetCookie("UserID");
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        try
        {   
            int UserID = Convert.ToInt32(Base.BasePage.GetCookie("UserID"));
            TUserInfo TUser = new TUserInfo();
            TUser.UserID = UserID;
            string Md5Pawd = Common.Encryption(this.txtOldPassword.Text);
            TUser.OldPassword = Md5Pawd;
            Md5Pawd = Common.Encryption(this.txtNewPassword.Text);
            TUser.Password = Md5Pawd;
            IUserInfo RUser = new RUserInfo();
            RUser.UpdatePassword(TUser);
            if (Response.Cookies["LoginName"] != null)
            {
                bool b = GetRequest.ClearCookie("LoginName");
            }
            if (Response.Cookies["UserId"] != null)
            {
                GetRequest.ClearCookie("UserId");
            }
            if (Response.Cookies["GradeID"] != null)
            {
                GetRequest.ClearCookie("GradeID");
            }
            ShowMessage("登录密码修改成功！请重新登陆", "../../Login/Login.aspx");        
        }
        catch (Exception ex)
        {
            ShowMessage(ex.Message);
        }
        this.txtOldPassword.Text = string.Empty;
        this.txtNewPassword.Text = string.Empty;
        this.txtNewPassword1.Text = string.Empty;
    }
  
}
